package de.hhbk.feedbackmodul.entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the fragebogen database table.
 * 
 */
@Entity
@Table(name="fragebogen")
public class QuestionSheet implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int id;

	@Column(length=50,nullable=false)
	private String bezeichnung;
	
	//bi-directional many-to-one association to User
    @ManyToOne
	@JoinColumn(name="fk_user")
	private User user;
	
	//bi-directional many-to-one association to Umfrage
	@OneToMany(mappedBy="fragebogen",fetch= FetchType.EAGER)
	private Set<Survey> umfrages = new HashSet<Survey>();
	
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "fragebogen_frage", joinColumns = { 
			@JoinColumn(name = "fk_fragebogen", nullable = false, updatable = false,unique=true) }, 
			inverseJoinColumns = { @JoinColumn(name = "fk_frage", 
					nullable = false, updatable = false,unique=true) })
	private Set<Question> fragen = new HashSet<Question>();

    public QuestionSheet() {
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Set<Survey> getUmfrages() {
		return this.umfrages;
	}

	public void setUmfrages(Set<Survey> umfrages) {
		this.umfrages = umfrages;
	}

	public Set<Question> getFragen() {
		return fragen;
	}

	public void setFragen(Set<Question> fragen) {
		this.fragen = fragen;
	}
	
	public String getBezeichnung() {
		return bezeichnung;
	}

	public void setBezeichnung(String bezeichnung) {
		this.bezeichnung = bezeichnung;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}